<html>
<head>
<title>D:\workspace\moincms\documents\examplecode\AttachInfo.py.html</title>
<meta name="Generator" content="Vim/7.0">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#ffdab9" text="#000000">
<pre>
<font color="#cd0000"> 1 </font><span style="background-color: #ffdab9"><font color="#000000">&quot;&quot;&quot;</font></span>
<font color="#cd0000"> 2 </font><font color="#c00058">    MoinMoin - AttachList Macro</font>
<font color="#cd0000"> 3 </font>
<font color="#cd0000"> 4 </font><font color="#c00058">    A macro to produce information about attached pages</font>
<font color="#cd0000"> 5 </font>
<font color="#cd0000"> 6 </font><font color="#c00058">    Usage: [[AttachInfo]]</font>
<font color="#cd0000"> 7 </font>
<font color="#cd0000"> 8 </font><font color="#c00058">    @copyright: 2004 Jacob Cohen, Nigel Metheringham</font>
<font color="#cd0000"> 9 </font><font color="#c00058">    @license: GNU GPL, see COPYING for details</font>
<font color="#cd0000">10 </font><span style="background-color: #ffdab9"><font color="#000000">&quot;&quot;&quot;</font></span>
<font color="#cd0000">11 </font>
<font color="#cd0000">12 </font><font color="#cd00cd">from</font> MoinMoin.action.AttachFile <font color="#cd00cd">import</font> info
<font color="#cd0000">13 </font>
<font color="#cd0000">14 </font>
<font color="#cd0000">15 </font><font color="#406090"># method name: execute</font>
<font color="#cd0000">16 </font><font color="#406090"># parameter: macro - MoinMoin.wikimacro.Macro instance</font>
<font color="#cd0000">17 </font><font color="#406090"># parameter: args - arguments from RAW data</font>
<font color="#cd0000">18 </font><font color="#804040"><b>def</b></font> <font color="#008080">execute</font>(macro, args):
<font color="#cd0000">19 </font>    pagename = macro.formatter.page.page_name
<font color="#cd0000">20 </font>    <font color="#406090"># print is a powerful debugging tool</font>
<font color="#cd0000">21 </font>    <font color="#406090"># be aware, you should use HTML syntax as well.</font>
<font color="#cd0000">22 </font>    <font color="#804040"><b>print</b></font> <span style="background-color: #ffdab9"><font color="#000000">'</font></span><font color="#c00058">&lt;I&gt;</font><span style="background-color: #ffdab9"><font color="#000000">'</font></span> + pagename + <span style="background-color: #ffdab9"><font color="#000000">'</font></span><font color="#c00058">&lt;I&gt;</font><span style="background-color: #ffdab9"><font color="#000000">'</font></span>
<font color="#cd0000">23 </font>    <font color="#804040"><b>if</b></font> args:
<font color="#cd0000">24 </font>        pagename = args
<font color="#cd0000">25 </font>    result = info(pagename, macro.request);
<font color="#cd0000">26 </font>    <font color="#406090"># the result is HTML code, so if you want to look at it use &lt;!-- --&gt;</font>
<font color="#cd0000">27 </font>    <font color="#406090"># Browser will ignore it</font>
<font color="#cd0000">28 </font>    <font color="#804040"><b>print</b></font> <span style="background-color: #ffdab9"><font color="#000000">'</font></span><font color="#c00058">&lt;!--</font><span style="background-color: #ffdab9"><font color="#000000">'</font></span> + result + <span style="background-color: #ffdab9"><font color="#000000">'</font></span><font color="#c00058">--&gt;</font><span style="background-color: #ffdab9"><font color="#000000">'</font></span>
<font color="#cd0000">29 </font>    <font color="#804040"><b>return</b></font> result
</pre>
</body>
</html>
